<template>
  <div class="car-models">
    <el-card>
      <el-form label-width="120px">
        <el-row type="flex">
          <el-col>
            <el-form-item label="车型编号：">
              <el-input></el-input>
            </el-form-item>
          </el-col>
          <el-col>
            <el-form-item label="应载重量：">
              <el-select v-model="value" placeholder="请选择">
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col>
            <el-form-item label="应载体积：">
              <el-select v-model="value" placeholder="请选择">
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row type="flex">
          <el-col :span="8">
            <el-form-item label="车辆类型：">
              <el-input></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8" style="margin-left: 100px">
            <el-button type="primary">搜索</el-button>
            <el-button>重置</el-button>
          </el-col>
        </el-row>
      </el-form>
    </el-card>
    <el-card style="margin-top: 20px">
      <el-button type="primary" style="margin-bottom: 20px">新增车型</el-button>
      <el-table
        :data="truckTypeList"
        border
        stripe
        :header-cell-style="{ background: '#f8faff', color: '#818693' }"
        style="margin-bottom: 20px"
      >
        <el-table-column type="index" label="序号"> </el-table-column>
        <el-table-column prop="id" label="车型编号" width="180">
        </el-table-column>
        <el-table-column prop="name" label="车辆类型"> </el-table-column>
        <el-table-column prop="num" label="车型数量"> </el-table-column>
        <el-table-column prop="allowableLoad" label="应载重量（吨）">
        </el-table-column>
        <el-table-column prop="allowableVolume" label="应载体积（立方米）">
        </el-table-column>
        <el-table-column prop="measureLong" label="长（米）"> </el-table-column>
        <el-table-column prop="measureWidth" label="宽（米）">
        </el-table-column>
        <el-table-column prop="measureHigh" label="高（米）"> </el-table-column>
        <el-table-column fixed="right" label="操作" width="100">
          <template #default="{ row }">
            <el-button @click="handleClick(row)" type="text">编辑</el-button>
            <el-button type="text">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryInfo.page"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="queryInfo.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="queryInfo.total"
      >
      </el-pagination>
    </el-card>
  </div>
</template>

<script>
import { getTruckTypeInfoApi } from "@/api/transit";
export default {
  data() {
    return {
      truckTypeList: [],
      queryInfo: {
        page: 1,
        pageSize: 10,
        total: 0,
      },
    };
  },
  methods: {
    async getTruckTypeInfo() {
      const res = await getTruckTypeInfoApi(this.queryInfo);
      console.log(res);
      this.truckTypeList = res.data.items;
      this.queryInfo.total = +res.data.counts;
    },
    // 分页
    handleSizeChange(newPageSize) {
      this.queryInfo.pageSize = newPageSize;
      this.getTruckTypeInfo();
    },
    handleCurrentChange(newPage) {
      this.queryInfo.page = newPage;
      this.getTruckTypeInfo();
    },
  },
  created() {
    this.getTruckTypeInfo();
  },
};
</script>

<style></style>
